

// INCLUDES ********************************************************************

#include "AccelerationController.h"

#include "AccelerationListener.h"



// NAMESPACES ******************************************************************

using namespace Meteor;


// FORWARD DECLARATIONS ********************************************************

// *****************************************************************************

#pragma mark -
#pragma mark Constructor/Destructor
// -----------------------------------------------------------------------------

AccelerationController::AccelerationController()
{
}

// -----------------------------------------------------------------------------

AccelerationController::~AccelerationController()
{
    
}


#pragma mark -
#pragma mark Listeners
// -----------------------------------------------------------------------------

void AccelerationController::AddAccelerationListener( AccelerationListener* listener)
{
    if ( mListeners.find( listener) != mListeners.end())
    {
        Logger::DebugLog( "AccelerationController::AddAccelerationListener - \
Listener already added.");
    }

    mListeners.insert( listener);
}

// -----------------------------------------------------------------------------

void AccelerationController::RemoveAccelerationListener( AccelerationListener* listener)
{
    containertype::iterator entry = mListeners.find( listener);

    if ( entry != mListeners.end())
    {
        mListeners.erase( entry);
    }
}

#pragma mark -
#pragma mark Notification
// -----------------------------------------------------------------------------

void AccelerationController::DeviceDidAccelerate( const float x, 
                                                  const float y, 
                                                  const float z)
{
    containertype::iterator listener = mListeners.begin();
    
    while( listener != mListeners.end())
    {
        ( *listener)->DeviceDidAccelerate( x, y, z);
    }
}

